use std::error::Error;
use std::fmt::{Debug, Display, Formatter};

#[derive(Clone)]
pub enum Errors {
    Empty,
    FromStr(String),
}

impl Errors {
    pub fn to_string(&self) -> String {
        return match self {
            Errors::Empty => { "data is empty".to_string() },
            Errors::FromStr(data) => {
                data.clone()
            }
            _ => {"".to_string()}
        };
    }

    pub fn to_dyn(&self) -> Box<Self> {
        Box::new(self.clone())
    }
}

impl Debug for Errors {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.to_string().as_str())
    }
}

impl Display for Errors {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.to_string().as_str())
    }
}

impl Error for Errors {

}